#include "TextureManager.h"

TextureManager *TextureManager::myInstance = NULL;
TextureManager *TextureManager::GetInst()
{
    if(myInstance == NULL)
        myInstance = new TextureManager;
    return myInstance;
}

TextureManager::TextureManager()
{
}

TextureManager::~TextureManager()
{
    for(myIterator = myTextures.begin();
        myIterator != myTextures.end();
        ++myIterator)
    {
        delete myIterator->second;
    }
}

Image *TextureManager::GetTexture(std::string name)
{
    myIterator = myTextures.find(name);

    if(myIterator == myTextures.end())
    {
        load(name);
        myIterator = myTextures.find(name);

    }

    return myIterator->second;

}



void TextureManager::load(std::string name)
{
    Image *image = new Image;
    image->Load(QString(name.c_str()));
    myTextures.insert(std::make_pair(name, image));
}
